home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Delphi Programmer's Power Pack
/
Delphi Volume 1.iso
/
e_to_l
/
isamexpt
/
isambrow.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1996-09-15
|
21KB
|
601 lines
unit Isambrow;
{copyright 1995 by Norbert Stellberg GmbH,
parts that are signed with a "*" copyright by TURBO POWER
or Michael Williams CompuServe: 71552,757 }
interface
uses
SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls,
LowBrows, Fvcbrows, Filer, IsamTabl;
type
Feld_GetProc = Function(Feld: Integer;
Table: TIsamTable;
var DATA): String;
{FELD_GETPROC will be created by the expert in
the browser-unit.
It will get the data-fields from your record.
Example:
Function TestGetFeldProc(Feld: Integer; Table: TIsamTable; var DATA): String; far;
var S: String;
begin
S:= '';
With TESTRECORD(Data) do begin
Case Feld of
1: s:= String_oem2ansi(Table.AnsiConvert,NAME1)+'^';
2: s:= String_oem2ansi(Table.AnsiConvert,NAME2)+'^';
3: s:= String_oem2ansi(Table.AnsiConvert,STREET)+'^';
4: s:= String_oem2ansi(Table.AnsiConvert,ZIP)+'^';
5: s:= String_oem2ansi(Table.AnsiConvert,CITY)+'^';
6: s:= DateStr(DATE)+'^';
7: s:= FormDezStr(AGE,10);
end;
end;
Result:= S;
end; }
TIsamBrowser = class(TFvcBrowser)
{a descendant of the TFVCBROWSER-Object, whose copyright is
by TURBO POWER INC.
Vars and Procs, signed by a "*" are copied from the TFVCBROWSER.
the copyright will still be held by TURBO POWER}
private
{ Private declarations }
FHeader : THeader; {a normal header for your browser}
FSpalten : TStringList; {a list of TUEBERSCHRIFTOBJECTS .. see ISBRINST.INT}
FTable : TIsamTable; {the isamtable, that will be browsed}
FKeySection : integer; { * Which header section are we searching on }
FSeparatorChar : char; { * Default '^' }
FJustLeftChar : char; { * Default #255 }
FJustRightChar : char; { * Default #255 }
FJustCenterChar : char; { * Default #255 }
FAllowIncss : boolean; { * }
FIncSSColor : TColor; { * }
FIncSSTxtColor : TColor; { * }
Procedure SetTable(const Value: TIsamTable);
Procedure SetSpalten(const Value: TStringList);
protected
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure KeyPress(var Key: Char); override;
function WriteStringOut(var S : BRLRowEltString;
LineNr : word;
XOfs : integer): word; override;
procedure ShowErrorOccured(EClass: Integer); override;
public
BaseLKey : IsamKeyStr; { * }
BaseHKey : IsamKeyStr; { * }
IncSS : IsamKeyStr; { * Incremental search string }
FTextMargin : TRect; { * }
Procedure ResizeHeader; {must be called after you changed the
field widths by drag and drop in your
browser}
Function ReadIni: Integer; {will read browser-settings from an ini-file,
{must be called after creating the form and
before showing the browser-form.}
Procedure SetupBrowser(aParent: TForm); {will show the browser-setup-dialog,
see ISBRINST.INT}
Function GetRow(GetProc: Feld_GetProc; var DATA):String;
{called by the browser to show the data fields}
Function GetLowBrowser: PLowWinBrowser;
published
{ Published declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
property BrowserHeader : THeader read FHeader write FHeader;
property Spalten : TStringList read FSpalten write SetSpalten;
property Table : TIsamTable read FTable write SetTable;
property KeySection : {*}integer read FKeySection write FKeySection;
property SeparatorChar : {*}char read FSeparatorChar write FSeparatorChar;
property JustLeftChar : {*}char read FJustLeftChar write FJustLeftChar;
property JustRightChar : {*}char read FJustRightChar write FJustRightChar;
property JustCenterChar : {*}char read FJustCenterChar write FJustCenterChar;
property AllowIncSS : {*}boolean read FAllowIncSS write FAllowIncSS;
property IncSSColor : {*}TColor read FIncSSColor write FIncSSColor;
property IncSSTxtColor : {*}TColor read FIncSSTxtColor write FIncSSTxtColor;
procedure ClearIncss; {*}
end;
Function GetAppName: String; {procedure, to get the name of your application during runtime}
implementation
Uses UToolDll, IniFiles, IsBrInst;
Var AppName: String;
Function GetAppName: String;
var G: String;
xPos: Integer;
begin
G:= Application.ExeName;
xPos:= Pos('\',G);
While xPos > 0 do begin
Delete(G,1,xPos);
xPos:= Pos('\',G);
end;
xPos:= Pos('.',G);
if xPos > 0 then G:= Copy(G,1,xPos-1);
AppName:= G;
GetAppName:= G;
end;
constructor TIsamBrowser.Create(AOwner : TComponent);
begin
Inherited Create(AOwner);
IncSS := '';
SeparatorChar := '^';
FJustLeftChar := #255;
FJustCenterChar := #255;
FJustRightChar := #255;
BaseLKey := LowKey;
BaseHKey := HighKey;
FIncSSColor := clRed;
FIncssTxtColor := clWhite;
FSpalten:= TStringList.Create;
end;
Function TIsamBrowser.GetLowBrowser: PLowWinBrowser;
begin
Result:= BrowserPtr;
end;
Destructor TIsamBrowser.Destroy;
begin
FSpalten.Free;
Inherited Destroy;
end;
Function TIsamBrowser.ReadIni: Integer;
var BrwListe,SListe: TStringList;
BrwIni: TIniFile;
FNr,K,i,Code,idx,Arr1,Arr2,Feld: Integer;
SStr,AktDir,LStr,LenStr,FeldName: String;
x,Len: Longint;
begin
AktDir:= ExtractFilePath(Application.ExeName);
K:= 1;
BrwIni:= TIniFile.Create(AktDir + GetAppName+'.INI');
BrwListe:= TStringList.Create;
SListe:= TStringList.Create;
K:= BrwIni.ReadInteger(Name+'Key','KeyNo',1);
BrwIni.ReadSection(Name,BrwListe);
if BrwListe.Count > 0 then begin
For i:= 0 to BrwListe.Count-1 do begin
LStr:= BrwIni.ReadString(Name,BrwListe[i],'');
if Pos(',',LStr) > 0 then begin
Val(Copy(LStr,1,Pos(',',LStr)-1),Len,Code);
Delete(LStr,1,Pos(',',LStr));
Val(LStr,Idx,Code);
end
else begin
Idx:= i+1;
Val(LStr,Len,Code);
end;
SListe.AddObject(BrwListe[i],TUeberschriftObject.Init(BrwListe[i],Idx,Len));
end;
Spalten:= SListe;
end
else begin
if Table <> NIL then begin
if Table.IsamRecord.Count > 0 then begin
FNr:= 0;
For i:= 0 to Table.IsamRecord.Count-1 do begin
SStr:= Table.IsamRecord[i];
if (Pos('DUMMY',Uppercase(SStr)) = 0) and (Pos('IGNORE',Uppercase(SStr)) = 0) then begin
Len:= 0;
if Pos(':',SStr) > 0 then begin
GetArray(SStr,Arr1,Arr2);
For Feld:= Arr1 to Arr2 do begin
FeldName:= Copy(SStr,1,Pos(':',SStr)-1);
Strip(FeldName);
if Arr1 <> Arr2 then FeldName:= FeldName + DezStr(Feld);
LenStr:= Uppercase(SStr);
Delete(LenStr,1,Pos(':',LenStr));
Strip(LenStr);
if Pos('ARRAY[',LenStr) > 0 then begin
Delete(LenStr,1,Pos('ARRAY[',LenStr));
Delete(LenStr,1,Pos(']',LenStr));
end;
if Pos('STRING',LenStr) > 0 then begin
if Pos('[',LenStr) > 0 then begin
Delete(LenStr,1,Pos('[',LenStr));
LenStr:= Copy(LenStr,1,Pos(']',LenStr)-1);
Val(LenStr,Len,Code);
end
else Len:= 255;
end
else if Pos('INTEGER',LenStr) > 0 then Len:= 8
else if Pos('WORD',LenStr) > 0 then Len:= 8
else if Pos('BYTE',LenStr) > 0 then Len:= 4
else if Pos('LONGINT',LenStr) > 0 then Len:= 10
else if Pos('REAL',LenStr) >